package ling.archives.domain;

import com.easy.query.core.enums.RelationTypeEnum;
import com.easy.query.core.proxy.ProxyEntityAvailable;
import com.fasterxml.jackson.annotation.JsonFormat;
import com.fasterxml.jackson.annotation.JsonIgnore;
import com.ruoyi.common.utils.StringUtils;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import java.io.Serializable;
import java.util.ArrayList;
import java.util.Date;

import ling.archives.common.DataUtil;
import ling.archives.domain.proxy.ArchiveContentProxy;
import lombok.Data;
import com.easy.query.core.annotation.*;
import ling.archives.common.domain.entity.*;
import lombok.var;

/**
 * 卷宗内容;
 * @author : He-LiangLiang@Outlook.com
 * @date : 2025-3-26
 */
@ApiModel(value = "卷宗内容",description = "")
@Table("ar_archive_content")
@EntityProxy
@Data
public class ArchiveContent extends IUpdatedEntity.LongId implements  Serializable,Cloneable, ProxyEntityAvailable<ArchiveContent , ArchiveContentProxy> {
    /** 租户号 */
    /*
    @Column(primaryKey = true)
    @ApiModelProperty(value = "租户号",notes = "")
    private Integer id ;
    */

    public static String gainFilesPathJson(ArchiveContent content, String basePath) {
        if (StringUtils.isNotBlank(basePath) && !basePath.endsWith("\\"))
            basePath += "\\";
//        if (content.getPageCount() == 1) {
            var pathStr = basePath + content.getFullNum() + ".pdf";
            return DataUtil.toJson(new String[]{pathStr});

//        }
//        else {
//            var pathArr = new ArrayList<String>();
//            for (int i = 1; i <= content.getPageCount(); i++) {
//                pathArr.add(basePath + content.getFullNum() + "-" + i + ".tif");
//            }
//            return DataUtil.toJson(pathArr);
//        }
//        else {
//            var pathArr = new ArrayList<String>();
//            pathArr.add(basePath + content.getFullNum() + ".tif");
//            for (int i = 1; i <= content.getPageCount()-1; i++) {
//                pathArr.add(basePath + content.getFullNum() + "-" + i + ".tif");
//            }
//            return DataUtil.toJson(pathArr);
//        }
    }
    public String[] gainFileArr(){
        return DataUtil.toObjByJson(getPageFiles(),String[].class);
    }
    @ApiModelProperty(value = "乡镇名称",notes = "")
    @EasyWhereCondition
    String townName;
    /** 村名 */
    @ApiModelProperty(value = "村名",notes = "")
    @EasyWhereCondition
    private String villageName ;


    /** 户主 */
    @ApiModelProperty(value = "户主",notes = "")
    @EasyWhereCondition(mode = EasyWhereCondition.Mode.MULTI_OR,propNames = {"householdHead","headPy"})
    private String householdHead ;


    /** 户主名称拼音;hz,huzhu */
    //@ApiModelProperty(value = "户主名称拼音",notes = "hz,huzhu")
    @EasyWhereCondition
    @JsonIgnore
    private String headPy ;


    /** 对应卷宗id */
    @ApiModelProperty(value = "对应卷宗id",notes = "")
    @EasyWhereCondition(type = EasyWhereCondition.Condition.EQUAL)
    private Long archiveId ;

    @Navigate(value = RelationTypeEnum.ManyToOne,targetProperty = "id", selfProperty = "archiveId")
    private Archive archive ;

    @ApiModelProperty(value = "对应卷宗档号",notes = "")
    private String archiveNum ;

    /** 文件档号;唯一 */
    @ApiModelProperty(value = "文件档号",notes = "唯一")
    @EasyWhereCondition(type = EasyWhereCondition.Condition.EQUAL)
    private String fullNum ;


    /** 文件题名;城关乡（镇）-北元村-李建喜-农宅存根 */
    @ApiModelProperty(value = "文件题名",notes = "城关乡（镇）-北元村-李建喜-农宅存根")
    @EasyWhereCondition
    private String title ;

    /** 根据属性得到一个新提名
     *
     * @return
     */
    public String gainTitle(){
        return getTownName()+"（镇）-"+getVillageName()+"-"+getHouseholdHead()+"-农宅存根";
    }
    /** 全宗名称 */
    @ApiModelProperty(value = "全宗名称",notes = "")
    private String fullArchiveName ;


    /** 全宗号 */
    @ApiModelProperty(value = "全宗号",notes = "")
    private String fullArchiveNum ;


    /** 年度;,数字：1990 */
    @ApiModelProperty(value = "年度",notes = ",数字：1990")
    private Integer year ;


    /** 保管期限;0永久 */
    @ApiModelProperty(value = "保管期限",notes = "0永久")
    private Integer retentionPeriod ;


    /** 案卷号 */
    @ApiModelProperty(value = "案卷号",notes = "")
    @EasyWhereCondition(type = EasyWhereCondition.Condition.EQUAL)
    private String num ;


    /** 卷内顺序号 */
    @ApiModelProperty(value = "卷内顺序号",notes = "")
    private Integer index ;


    /** 日期 */
    @ApiModelProperty(value = "日期",notes = "")
    @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss")
    private Date fileDate ;


    /** 管理者，责任人 */
    @ApiModelProperty(value = "管理者，责任人",notes = "")
    private String manager ;


    /** 页次 */
    @ApiModelProperty(value = "页次",notes = "")
    private Integer pageIndex ;


    /** 页数 */
    @ApiModelProperty(value = "页数",notes = "")
    private Integer pageCount ;


    /** 物理文件列表;json数组，多个 */
    @ApiModelProperty(value = "物理文件列表",notes = "json数组，多个")
    private String pageFiles ;


    /** 关键字 */
    @ApiModelProperty(value = "关键字",notes = "")
    private String keyword ;


    /** 部门说明 */
    @ApiModelProperty(value = "部门说明",notes = "")
    private String orgDescr ;


    /** 备注 */
    @ApiModelProperty(value = "备注",notes = "")
    private String reamrk ;
    

    /** 0正常，2已作废 */
    @ApiModelProperty(value = "0正常，2已作废",notes = "")
    @EasyWhereCondition(type = EasyWhereCondition.Condition.EQUAL)
    private String status ;

}